package com.sc.nft.mapper;

import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.sc.nft.entity.UserMerchantPledgeTaskRecords;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.sc.nft.entity.vo.MerchantPledgeDataExportPreviewVO;
import com.sc.nft.entity.vo.MerchantUserPledgeTaskPageVO;
import com.sc.nft.entity.vo.UserMerchantPledgeTaskRecordDetailsVO;
import com.sc.nft.entity.vo.UserPledgeTaskRwardsDetailsVO;
import com.sc.nft.entity.vo.merchantPledgeTask.TreasureRecordDetailsVO;
import com.sc.nft.entity.vo.merchantPledgeTask.TreasureRecordPageVO;
import com.sc.nft.enums.UserMerchantPledgeTaskStatusEnum;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;

import java.util.Date;
import java.util.List;

/**
 * 用户商户质押任务记录表(sc_user_merchant_pledge_task_records)数据Mapper
 *
 * @author Sun
 * @since 2023-08-24 16:16:30
 * @description 由 Mybatisplus Code Generator 创建
*/
@Mapper
public interface UserMerchantPledgeTaskRecordsMapper extends BaseMapper<UserMerchantPledgeTaskRecords> {

    /**
     *  挖宝记录
     * @param page
     * @param userId
     * @return
     */
    Page<TreasureRecordPageVO> treasureRecordPage(Page page,@Param("userId") Long userId);

    /**
     * 挖宝详情
     * @param userId
     * @param id
     * @return
     */
    TreasureRecordDetailsVO treasureRecordDetails(@Param("userId") Long userId,@Param("id") Long id);

    /**
     * 获取即将过期的订单
     * @param status
     * @return
     */
    List<UserMerchantPledgeTaskRecords> getExpireList(@Param("status") Integer status);

    /**
     * 获取用户id集合的质押记录的份数之和
     * @param merchantPledgeTaskId
     * @param ids
     * @return
     */
    Integer getCountByJuniorIdsAndMerchantPledgeTaskId(@Param("merchantPledgeTaskId") Long merchantPledgeTaskId,@Param("ids") List<Long> ids);

    /**
     * 获取用户id集合的质押记录的藏品数量之和
     * @param userId
     * @param merchantPledgeTaskId
     * @return
     */
    Integer getSumPledgeCountByUserIdAndMerchantPledgeTaskId(@Param("userId") Long userId,@Param("merchantPledgeTaskId") Long merchantPledgeTaskId);

    Integer getCountMerchantPledgeTaskId(@Param("merchantPledgeTaskId") Long merchantPledgeTaskId);

    /**
     * 分页查询用户商户质押任务记录
     * @param page
     * @param daoName
     * @param userTel
     * @param pledgeName
     * @param status
     * @return
     */
    Page<MerchantUserPledgeTaskPageVO> getMerchantUserPledgeTaskRecordPage(Page page, @Param("daoName") String daoName,@Param("userTel") String userTel,@Param("pledgeName") String pledgeName, @Param("status") Integer status,@Param("isFrozen") Boolean isFrozen);

    /**
     * 用户质押任务详情
     * @param id
     * @return
     */
    UserMerchantPledgeTaskRecordDetailsVO userPledgeTaskRecordDetails(@Param("id") Long id);

    /**
     * 分页获取质押留的奖励
     * @param page
     * @param id
     * @param startTime
     * @param endTime
     * @return
     */
    Page<UserPledgeTaskRwardsDetailsVO> getMerchantUserPledgeTaskRwardsDetails(Page page,@Param("id") Long id,@Param("startTime") Date startTime,@Param("endTime") Date endTime);

    /**
     * 导出数据预览
     * @param pledgeName
     * @param daoId
     * @return
     */
    List<MerchantPledgeDataExportPreviewVO> merchantPledgeDataExportPreview(@Param("pledgeName") String pledgeName, @Param("daoId") Long daoId);

    /**
     * 获取用户id的质押记录的份数之和 (未开始和进行中的)
     * @param userId
     * @param id
     * @return
     */
    Integer getSumPledgeCountByUserIdAndMerchantPledgeTaskIdAndStatus(@Param("userId") Long userId,@Param("merchantPledgeTaskId") Long merchantPledgeTaskId);
}
